<template>
	<view class="bjfff">
		<block v-for="(i, j) in typeList" :key="j">
			<view class="flex-between v-entrance" @click="toGo(i.url)" v-if="i.isTrue == 1">
				<view class="flex-align-center v-icon">
					<image :src="i.img"></image>
					<view>{{ i.text }}</view>
				</view>
				<image class="v-arrow-right" src="/static/arrowRight.png"></image>
			</view>
		</block>
		<!-- ‘客服联系’ -->
		<sunui-popup ref="pop">
			<template v-slot:content>
				<view class="v-pop flex-column">
					<view class="v-pop-phone flex" @click="call()">
						<image src="/static/my/phone.png"></image>
						{{ kfPhone }}
					</view>
					<view class="v-cancel flex" @click="cancel()">取消</view>
				</view>
			</template>
		</sunui-popup>
	</view>
</template>

<script>
export default {
	name: 'list',
	props: ['typeList'],
	data() {
		return {
			uid: uni.getStorageSync('uid'),
			// 系统设置:客服电话号码
			kfPhone: uni.getStorageSync('system').kf_phone
		};
	},
	methods: {
		// 拨打电话
		call() {
			this.$sun.phone(this.kfPhone);
		},
		// "客服联系" 取消按钮
		cancel() {
			this.$refs.pop.close();
		}
		// 判断登录
		handleLogin() {
			if (this.uid) {
				return true;
			} else {
				uni.navigateTo({
					url: `/pages/login/login`
				});
			}
		},
		toGo(url) {
			/* if (this.handleLogin()) {
				if (url) {
					this.$sun.navGo(url);
				}
				// 当前列表只有“客服联系”不存在url
				else {
					this.$refs.pop.show({
						anim: 'bottom',
						position: 'bottom',
						shadeClose: false, //false使用户不能点击其它关闭页面
						topclose: false
					});
				}
			} */

			if (!url) {
				this.$refs.pop.show({
					anim: 'bottom',
					position: 'bottom',
					shadeClose: false, //false使用户不能点击其它关闭页面
					topclose: false
				});
			} else {
				if (this.handleLogin()) {
					this.$sun.navGo(url);
				}
			}
		},
		
	}
};
</script>

<style lang="less">
//  :not(:last-child)
.v-entrance {
	padding: 30rpx 42rpx 26rpx 46rpx;
	border-bottom: 2rpx solid #f7f7f7;
	.v-icon {
		image {
			width: 48rpx;
			height: 48rpx;
			margin-right: 22rpx;
		}
	}
	.v-arrow-right {
		width: 12rpx;
		height: 22rpx;
	}
}

// 客服联系
.v-pop {
	width: 750rpx;
	background-color: #ffffff;
	border-radius: 20rpx 20rpx 0 0;
	.v-pop-phone {
		width: 100%;
		border-bottom: 2rpx solid #f7f7f7;
		color: #08ba06;
		font-size: 32rpx;
		padding: 36rpx 0 32rpx;
		image {
			width: 38rpx;
			height: 38rpx;
			margin-right: 12rpx;
		}
	}
	.v-cancel {
		width: 100%;
		padding: 36rpx 0;
		color: #8f8f8f;
		font-size: 32rpx;
	}
}
</style>
